/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package asteroidmining1;

/**
 *
 * @author IVAN
 */
public class CannonBall extends MoveableBall {

    public static double GRAVITY_EFFECT = 0.2;
    public static int Quadrante = 0;
    
    private double  maxvx, maxvy;

    public CannonBall(int sx, int sy, int r, double dx, double dy) {
        super(sx, sy, r, dx, dy);
    }

    public void move() {
        double valueX, valueY;
        valueX = xMotion();
        valueY = yMotion();
                
        switch (Quadrante) {
            case 0:
                //MU
                setMotion(xMotion(), yMotion());
                break;
            case 1:
                //1º Quad.
                if( Math.abs(xMotion() - GRAVITY_EFFECT) < Math.abs(maxvx))
                    valueX = xMotion() - GRAVITY_EFFECT;
                if( Math.abs(yMotion() + GRAVITY_EFFECT) < Math.abs(maxvy))
                    valueY = yMotion() + GRAVITY_EFFECT;
                
                    setMotion( valueX ,valueY );
                break;
            case 2:
                //2º Quad.
                
                if( Math.abs(xMotion() + GRAVITY_EFFECT) < Math.abs(maxvx))
                    valueX = xMotion() + GRAVITY_EFFECT;
                if( Math.abs(yMotion() + GRAVITY_EFFECT) < Math.abs(maxvy))
                    valueY = yMotion() + GRAVITY_EFFECT;
                
                setMotion( valueX, valueY );
                break;
            case 3:
                //3º Quad.
                if( Math.abs(xMotion() + GRAVITY_EFFECT) < Math.abs(maxvx))
                    valueX = xMotion() + GRAVITY_EFFECT;
                if( Math.abs(yMotion() - GRAVITY_EFFECT) < Math.abs(maxvy))
                    valueY = yMotion() - GRAVITY_EFFECT;
                
                setMotion( valueX, valueY );                                
                break;
            case 4:
                //4º Quad.
                if( Math.abs(xMotion() - GRAVITY_EFFECT) < Math.abs(maxvx))
                    valueX = xMotion() - GRAVITY_EFFECT;
                if( Math.abs(yMotion() - GRAVITY_EFFECT) < Math.abs(maxvy))
                    valueY = yMotion() - GRAVITY_EFFECT;
                                                
                setMotion( valueX ,valueY);
                break;

            case 5:
                //->
                if( Math.abs(xMotion() + GRAVITY_EFFECT) < Math.abs(maxvx))
                    valueX = xMotion() + GRAVITY_EFFECT;
                
                setMotion(valueX, yMotion());
                break;

            case 6:
                //<-
                if( Math.abs(xMotion() - GRAVITY_EFFECT) < Math.abs(maxvx))
                    valueX = xMotion() - GRAVITY_EFFECT;                
                                                                
                setMotion(valueX, yMotion() );
                break;

            case 7:
                // |
                // V                
                if( Math.abs(yMotion() + GRAVITY_EFFECT) < Math.abs(maxvy))
                    valueY = yMotion() + GRAVITY_EFFECT;
                                                                
                setMotion(xMotion() ,valueY );
                break;

            case 8:
                // A
                // |                
                if( Math.abs(yMotion() - GRAVITY_EFFECT) < Math.abs(maxvy))
                    valueY = yMotion() - GRAVITY_EFFECT;
                                                                
                setMotion(xMotion() , valueY);
                break;

        }
        //setMotion(xMotion() + GRAVITY_EFFECT, yMotion() + GRAVITY_EFFECT);
        //Sem gravidade
        //setMotion(xMotion(), yMotion());

        super.move();
    }
    
    /**
     * @return the maxvx
     */
    public double getMaxvx() {
        return maxvx;
    }

    /**
     * @param maxvx the maxvx to set
     */
    public void setMaxvx(double maxvx) {
        this.maxvx = maxvx;
    }

    /**
     * @return the maxvy
     */
    public double getMaxvy() {
        return maxvy;
    }

    /**
     * @param maxvy the maxvy to set
     */
    public void setMaxvy(double maxvy) {
        this.maxvy = maxvy;
    }
}